var aTreasureTest = (function () {

  var aTreasureTest = {};

  var clickUtils$4 = {
    getRateX(x, w) {
      return parseInt(x * (device.width / (w || device.width)));
    },
    getRateY(y, h) {
      return parseInt(y * (device.height / (h || device.height)));
    },
    clickXY(x, y) {
      var showing = console.showing;
      if (showing) {
        console.hide();
        sleep(0.1 * 1000);
      }
      click(x, y);
      if (showing) {
        console.show();
      }
    },
    clickXYZW(x, y, z, w, deltaX, deltaY) {
      deltaX = deltaX || 1;
      deltaY = deltaY || 1;
      this.clickXY(
        random(x + deltaX, z - deltaX),
        random(y + deltaY, w - deltaY)
      );
    },
    clickBounds(bounds, deltaX, deltaY) {
      var left = bounds.left;
      var right = bounds.right;
      var top = bounds.top;
      var bottom = bounds.bottom;
      this.clickXYZW(left, top, right, bottom, deltaX, deltaY);
    },
    clickPointMap(pointMap, deltaX, deltaY) {
      var point = pointMap[0];
      var width = pointMap[1];
      var height = pointMap[2];
      var x = this.getRateX(point[0], width);
      var y = this.getRateY(point[1], height);
      var z = this.getRateX(point[2], width);
      var w = this.getRateY(point[3], height);
      this.clickXYZW(x, y, z, w, deltaX, deltaY);
    },
    clickTextUI(TextUI, deltaX, deltaY) {
      this.clickBounds(TextUI.bounds(), deltaX, deltaY);
    },
    clickTextOCR(TextOCR, deltaX, deltaY) {
      this.clickBounds(TextOCR.bounds, deltaX, deltaY);
    },
  };

  var randomUtils$6 = {
    getRandom(start, end, span) {
      span = span || 1;
      return random(start * span, end * span);
    },
    possible(start, end, span) {
      var span = span || 100;
      var v = this.getRandom(1, span);
      if (v < start || v > end) {
        return false;
      } else {
        return true;
      }
    },
  };

  var TEXT_MAX_SEARCH_TIME = 10000; //搜索控件时超时时间 http://doc.autoxjs.com/#/widgetsBasedAutomation?id=uiselectorfindonetimeout
  var clickUtils$3 = clickUtils$4;
  var textUtils$4 = {
    existsText(content, ignoreLog) {
      if (text(content).exists()) {
        var TextUI = text(content).findOne(TEXT_MAX_SEARCH_TIME);
        if (!ignoreLog && TextUI) {
          console.log("existsText", "找到：", content, "/", TextUI.text());
        }
        return TextUI;
      } else {
        return false;
      }
    },
    existsTextStartsWith(content, ignoreLog) {
      if (textStartsWith(content).exists()) {
        var TextUI = textStartsWith(content).findOne(TEXT_MAX_SEARCH_TIME);
        if (!ignoreLog && TextUI) {
          console.log(
            "existsTextStartsWith",
            "找到：",
            content,
            "/",
            TextUI.text()
          );
        }
        return TextUI;
      } else {
        return false;
      }
    },
    existsTextEndsWith(content, ignoreLog) {
      if (textEndsWith(content).exists()) {
        var TextUI = textEndsWith(content).findOne(TEXT_MAX_SEARCH_TIME);
        if (!ignoreLog && TextUI) {
          console.log(
            "existsTextEndsWith",
            "找到：",
            content,
            "/",
            TextUI.text()
          );
        }
        return TextUI;
      } else {
        return false;
      }
    },
    existsTextMatches(contentRegExp, ignoreLog) {
      if (textMatches(contentRegExp).exists()) {
        var TextUI = textMatches(contentRegExp).findOne(TEXT_MAX_SEARCH_TIME);
        if (!ignoreLog) {
          console.log(
            "existsTextMatches",
            "找到：",
            contentRegExp,
            "/",
            TextUI.text()
          );
        }
        return TextUI;
      } else {
        return false;
      }
    },
  };
  var clickMethods = [
    ["existsText", "clickText"],
    ["existsTextStartsWith", "clickTextStartsWith"],
    ["existsTextEndsWith", "clickTextEndsWith"],
    ["existsTextMatches", "clickTextMatches"],
  ];
  var oneMethods = [
    ["existsText", "existsOneText"],
    ["existsTextStartsWith", "existsOneTextStartsWith"],
    ["existsTextEndsWith", "existsOneTextEndsWith"],
    ["existsTextMatches", "existsOneTextMatches"],
  ];
  var allMethods = [
    ["existsText", "existsAllText"],
    ["existsTextStartsWith", "existsAllTextStartsWith"],
    ["existsTextEndsWith", "existsAllTextEndsWith"],
    ["existsTextMatches", "existsAllTextMatches"],
  ];
  clickMethods.forEach(function (method) {
    var oldMethod = method[0];
    var newMethod = method[1];
    textUtils$4[newMethod] = function (content, ignoreLog) {
      var TextUI = this[oldMethod](content, true);
      if (TextUI) {
        if (!ignoreLog) {
          console.log(newMethod, "找到:", content, "/", TextUI.text());
        }
        clickUtils$3.clickTextUI(TextUI);
        return TextUI;
      } else {
        return false;
      }
    };
    return false;
  });
  oneMethods.forEach(function (method) {
    var oldMethod = method[0];
    var newMethod = method[1];
    textUtils$4[newMethod] = function (contents, ignoreLog) {
      if (!Array.isArray(contents)) {
        contents = [contents];
      }
      for (var index = 0; index < contents.length; index++) {
        var content = contents[index];
        var TextUI = this[oldMethod](content, true);
        if (TextUI) {
          if (!ignoreLog) {
            console.log(
              newMethod,
              "找到",
              contents.join("|"),
              "/",
              TextUI.text()
            );
          }
          return TextUI;
        }
      }
      return false;
    };
  });
  allMethods.forEach(function (method) {
    var oldMethod = method[0];
    var newMethod = method[1];
    var findText = [];
    textUtils$4[newMethod] = function (contents, ignoreLog) {
      if (!Array.isArray(contents)) {
        contents = [contents];
      }
      for (var index = 0; index < contents.length; index++) {
        var content = contents[index];
        var TextUI = this[oldMethod](content, true);
        if (!TextUI) {
          return false;
        } else {
          findText.push(TextUI.text());
        }
      }
      if (!ignoreLog) {
        console.log(
          newMethod,
          "全部找到",
          contents.join("|"),
          "/",
          findText.join("|")
        );
      }
      return true;
    };
  });

  var textUtils_1 = textUtils$4;

  var dateRegex = /(?=(YYYY|YY|MM|DD|HH|mm|ss|ms))\1([:\/]*)/g;
  var timeSpan = {
    YYYY: ["getFullYear", 4],
    YY: ["getFullYear", 2],
    MM: ["getMonth", 2, 1], // getMonth is zero-based, thus the extra increment field
    DD: ["getDate", 2],
    HH: ["getHours", 2],
    mm: ["getMinutes", 2],
    ss: ["getSeconds", 2],
    ms: ["getMilliseconds", 3],
  };
  var timeUtils$3 = {
    hasExec(startTime) {
      var now = Date.now();
      return (now - startTime) / 1000;
    },
    str(str, date, utc) {
      if (typeof str !== "string") {
        date = str;
        // str = "YYYY-MM-DD HH:mm:ss";
        str = "YYYY-MM-DD";
      }

      if (!date) date = new Date();
      return str.replace(dateRegex, function (match, key, rest) {
        var args = timeSpan[key];
        var name = args[0];
        var chars = args[1];
        if (utc === true) name = "getUTC" + name.slice(3);
        var val = "00" + String(date[name]() + (args[2] || 0));
        return val.slice(-chars) + (rest || "");
      });
    },
  };

  var timeUtils$2 = timeUtils$3;
  var randomUtils$5 = randomUtils$6;

  function bezier_curves(cp, t) {
    cx = 3.0 * (cp[1].x - cp[0].x);
    bx = 3.0 * (cp[2].x - cp[1].x) - cx;
    ax = cp[3].x - cp[0].x - cx - bx;
    cy = 3.0 * (cp[1].y - cp[0].y);
    by = 3.0 * (cp[2].y - cp[1].y) - cy;
    ay = cp[3].y - cp[0].y - cy - by;

    tSquared = t * t;
    tCubed = tSquared * t;
    result = {
      x: 0,
      y: 0,
    };
    result.x = ax * tCubed + bx * tSquared + cx * t + cp[0].x;
    result.y = ay * tCubed + by * tSquared + cy * t + cp[0].y;
    return result;
  }

  //仿真随机带曲线滑动
  //qx, qy, zx, zy, time 代表起点x,起点y,终点x,终点y,过程耗时单位毫秒
  function swipeX(qx, qy, zx, zy, time) {
    var xxy = [time];
    var point = [];
    var dx0 = {
      x: qx,
      y: qy,
    };

    var dx1 = {
      x: random(qx - 100, qx + 100),
      y: random(qy, qy + 50),
    };
    var dx2 = {
      x: random(zx - 100, zx + 100),
      y: random(zy, zy + 50),
    };
    var dx3 = {
      x: zx,
      y: zy,
    };
    point.push(dx0);
    point.push(dx1);
    point.push(dx2);
    point.push(dx3);

    for (let i = 0; i < 1; i += 0.08) {
      xxyy = [
        parseInt(bezier_curves(point, i).x),
        parseInt(bezier_curves(point, i).y),
      ];

      xxy.push(xxyy);
    }

    gesture.apply(null, xxy);
  }
  var swipeUtils$1 = {
    swipeX: swipeX,
    swipeUp() {
      var configs = [
        [
          60,
          100,
          device.width / 2,
          (device.height / 10) * 5,
          device.width / 2,
          (device.height / 10) * 2,
        ],
        [
          40,
          60,
          device.width / 2,
          (device.height / 10) * 6,
          device.width / 2,
          (device.height / 10) * 3,
        ],
        [
          30,
          40,
          device.width / 2,
          (device.height / 10) * 7,
          device.width / 2,
          (device.height / 10) * 2,
        ],
        [
          1,
          30,
          device.width / 2,
          (device.height / 10) * 8,
          device.width / 2,
          (device.height / 10) * 5,
        ],
      ];
      for (var index = 0; index < configs.length; index++) {
        var config = configs[index];
        if (randomUtils$5.possible(config[0], config[1])) {
          this.swipeX(
            config[2] + randomUtils$5.getRandom(0, 30),
            config[3] + randomUtils$5.getRandom(0, 30),
            config[4] + randomUtils$5.getRandom(0, 30),
            config[5] + randomUtils$5.getRandom(0, 30),
            randomUtils$5.getRandom(350, 800)
          );
          return;
        }
      }
    },
    swipeDown() {
      var configs = [
        [
          60,
          100,
          device.width / 3,
          device.height / 2,
          device.width / 3 + 20,
          device.height / 2 - device.height / 5,
        ],
        [
          40,
          60,
          device.width / 5,
          device.height / 3,
          device.width / 5 + 20,
          device.height / 3 - device.height / 6,
        ],
        [
          30,
          40,
          (device.width / 7) * 2,
          device.height / 4,
          (device.width / 7) * 2 + 20,
          device.height / 4 - device.height / 7,
        ],
        [
          1,
          30,
          device.width / 9,
          device.height / 5,
          device.width / 9 + 20,
          device.height / 5 - device.height / 8,
        ],
      ];
      for (var index = 0; index < configs.length; index++) {
        var config = configs[index];
        if (randomUtils$5.possible(config[0], config[1])) {
          this.swipeX(
            config[4] + randomUtils$5.getRandom(0, 30),
            config[5] + randomUtils$5.getRandom(0, 30),
            config[2] + randomUtils$5.getRandom(0, 30),
            config[3] + randomUtils$5.getRandom(0, 30),
            randomUtils$5.getRandom(200, 500)
          );
          return;
        }
      }
    },
    swipeRead(span, maxUp) {
      span = span || 60;
      span = randomUtils$5.getRandom(span, span + 5);
      maxUp = randomUtils$5.getRandom(maxUp, maxUp + 2);
      var startTime = Date.now();
      var count = 0;
      while (true) {
        count++;
        if (count < maxUp) {
          if (count % 3 == 0) {
            console.log("swipeRead:", "向上滑动一次");
          }
          this.swipeUp();
        } else {
          if (randomUtils$5.possible(1, 90)) {
            if (count % 3 == 0) {
              console.log("swipeRead:", "向上滑动一次");
            }
            this.swipeUp();
          } else {
            if (count % 3 == 0) {
              console.log("swipeRead:", "向下滑动一次");
            }
            this.swipeDown();
          }
        }
        sleep(randomUtils$5.getRandom(1.5, 3, 1000));
        var hasRead = timeUtils$2.hasExec(startTime);
        if (count % 5 == 0) {
          console.log("swipeRead:", hasRead, "/", span);
        }
        if (hasRead >= span) {
          if (count % 5 != 0) {
            console.log("swipeRead:", hasRead, "/", span);
          }
          break;
        }
      }
    },
    swipeVideo() {
      var configs = [
        [
          60,
          100,
          device.width / 2,
          (device.height / 10) * 7,
          device.width / 2 + 20,
          (device.height / 10) * 1 - 50,
        ],
        [
          40,
          60,
          device.width / 2,
          (device.height / 10) * 7,
          device.width / 2 + 20,
          (device.height / 10) * 1.5 - 80,
        ],
        [
          30,
          40,
          device.width / 2,
          (device.height / 10) * 8,
          device.width / 2 + 20,
          (device.height / 10) * 1.8 - 80,
        ],
        [
          1,
          30,
          device.width / 2,
          (device.height / 10) * 8.5,
          device.width / 2 + 20,
          (device.height / 10) * 2 - 80,
        ],
      ];
      for (var index = 0; index < configs.length; index++) {
        var config = configs[index];
        if (randomUtils$5.possible(config[0], config[1])) {
          this.swipeX(
            config[2] + randomUtils$5.getRandom(0, 30),
            config[3] + randomUtils$5.getRandom(0, 30),
            config[4] + randomUtils$5.getRandom(0, 30),
            config[5] + randomUtils$5.getRandom(0, 30),
            randomUtils$5.getRandom(350, 800)
          );
          return;
        }
      }
    },
  };

  var ocrCharMap$1 = {
    搜: ["嫂", "樓", "接", "楼"],
    赚: ["廉", "嫌", "賺", "兼"],
    看: ["着", "春"],
    文: ["女"],
    章: ["拿"],
    钱: ["线"],
    觉: ["党"],
    户: ["戶"],
    索: ["素"],
    开: ["升", "研"],
    金: ["全"],
    积: ["枳"],
    币: ["市"],
    现: ["現"],
    领: ["領", "颌"],
    读: ["渎"],
    额: ["額"],
    取: ["驭"],
    视: ["规", "初"],
    享: ["亨"],
    兑: ["兌"],
    提: ["堤"],
    体: ["休"],
    才: ["オ"],
    街: ["衔"],
    城: ["械"],
    间: ["闻"],
    来: ["來"],
    幕: ["慕"],
    十: ["+"],
  };
  var ocrCharMap_1 = ocrCharMap$1;

  var randomUtils$4 = randomUtils$6;
  var swipeUtils = swipeUtils$1;
  var ocrCharMap = ocrCharMap_1;

  if (!requestScreenCapture()) {
    toastLog("请求截图权限失败");
    exit();
  }
  function toArray(arrLike) {
    var array = [];
    for (var index = 0; index < arrLike.length; index++) {
      array.push(arrLike[index]);
    }
    return array;
  }
  function getCaptureImg() {
    var startTime = Date.now();
    var showing = console.showing;
    if (showing) {
      console.hide();
      sleep(0.1 * 1000);
    }
    var captureImg = captureScreen();
    if (showing) {
      console.show();
    }
    if (!captureImg) {
      toastLog("截图失败");
    }
    var endTime = Date.now();
    console.log("getCaptureImg: 截图耗费-" + (endTime - startTime) / 1000 + "-s");
    return captureImg;
  }
  function getOcrResults() {
    var captureImg = getCaptureImg();
    var ocrResults = toArray(gmlkit.ocr(captureImg, "zh").toArray(3));
    setTimeout(() => {
      captureImg.recycle();
    });
    return ocrResults;
  }
  var ocrUtils$4 = {
    getRegExpConfig(content) {
      var regExpStr = content
        .split("")
        .map(function (item) {
          var match = ocrCharMap[item];
          var piece = match
            ? "[" + match.concat(item).join("") + "]+"
            : "[" + item + "]+";
          return piece + `\\s*`;
        })
        .join("");
      return {
        text: content,
        regExp: new RegExp(regExpStr, "gi"),
      };
    },
    captureAndLog() {
      var ocrResults = getOcrResults();
      this.logOcrResults(ocrResults);
    },
    logOcrResults(ocrResults) {
      console.log(
        "logOcrResults:",
        "\n",
        ocrResults.map((item) => item.text).join(",")
      );
    },
    ocrResultsExist(ocrResults, regExpConfig) {
      for (var index = 0; index < ocrResults.length; index++) {
        var ocrResult = ocrResults[index];
        if (regExpConfig.regExp.test(ocrResult.text)) {
          return ocrResult;
        }
      }
      return false;
    },
    regExpConfigExist(ocrResults, regExpConfigs) {
      for (var index = 0; index < ocrResults.length; index++) {
        var ocrResult = ocrResults[index];
        for (var index2 = 0; index2 < regExpConfigs.length; index2++) {
          var regExpConfig = regExpConfigs[index2];
          if (regExpConfig.regExp.test(ocrResult.text)) {
            return ocrResult;
          }
        }
      }
      return false;
    },
    regExpConfigExistSome(ocrResults, regExpConfigs) {
      var results = [];
      for (var index = 0; index < ocrResults.length; index++) {
        var ocrResult = ocrResults[index];
        for (var index2 = 0; index2 < regExpConfigs.length; index2++) {
          var regExpConfig = regExpConfigs[index2];
          if (regExpConfig.regExp.test(ocrResult.text)) {
            results.push(ocrResult);
          }
        }
      }
      return results;
    },
    captureExistsText(content, logOcrResults, ignoreLog) {
      var regExpConfig = this.getRegExpConfig(content);
      var ocrResults = getOcrResults();
      var ocrResult = this.ocrResultsExist(ocrResults, regExpConfig);
      if (ocrResult) {
        if (!ignoreLog) {
          console.log(
            "captureExistsText:",
            "找到",
            regExpConfig.text,
            "/",
            ocrResult.text
          );
        }
        return ocrResult;
      } else {
        if (logOcrResults) {
          this.logOcrResults(ocrResults);
        }
        return false;
      }
    },
    captureExistsOneText(contents, logOcrResults, ignoreLog) {
      if (!Array.isArray(contents)) {
        contents = [contents];
      }
      var ocrResults = getOcrResults();
      var regExpConfigs = contents.map((content) =>
        this.getRegExpConfig(content)
      );
      var ocrResult = this.regExpConfigExist(ocrResults, regExpConfigs);
      if (ocrResult) {
        if (!ignoreLog) {
          console.log(
            "captureExistsOneText:",
            "找到",
            contents.join(","),
            "/",
            ocrResult.text
          );
        }
        return ocrResult;
      } else {
        console.log("captureExistsOneText:", "没找到", contents.join(","));
        if (logOcrResults) {
          this.logOcrResults(ocrResults);
        }
        return false;
      }
    },
    captureExistsSomeText(contents, logOcrResults, ignoreLog) {
      if (!Array.isArray(contents)) {
        contents = [contents];
      }
      var ocrResults = getOcrResults();
      var regExpConfigs = contents.map((content) =>
        this.getRegExpConfig(content)
      );
      var results = this.regExpConfigExistSome(ocrResults, regExpConfigs);
      if (results.length > 0) {
        if (!ignoreLog) {
          console.log(
            "captureExistsOneText:",
            "找到",
            contents.join(","),
            "/",
            results.map((item) => item.text).join(",")
          );
        }
        return results;
      } else {
        console.log("captureExistsOneText:", "没找到", contents.join(","));
        if (logOcrResults) {
          this.logOcrResults(ocrResults);
        }
        return false;
      }
    },

    captureExistsAllText(contents, logOcrResults, ignoreLog) {
      if (!Array.isArray(contents)) {
        contents = [contents];
      }
      var ocrResults = getOcrResults();
      var regExpConfigs = contents.map((content) =>
        this.getRegExpConfig(content)
      );
      var findResults = [];
      for (var index = 0; index < regExpConfigs.length; index++) {
        var regExpConfig = regExpConfigs[index];
        var ocrResult = this.ocrResultsExist(ocrResults, regExpConfig);
        if (ocrResult) {
          findResults.push(ocrResult);
        }
      }
      if (findResults.length == contents.length) {
        if (!ignoreLog) {
          console.log(
            "captureExistsAllText:",
            "找到",
            "\n",
            contents.join(","),
            "\n",
            findResults.map((item) => item.text).join(",")
          );
        }
        return true;
      } else {
        console.log("captureExistsAllText:", "没找到", contents.join(","));
        if (logOcrResults) {
          this.logOcrResults(ocrResults);
        }
        return false;
      }
    },
    scrollAndFindSome(contents, logOcrResults, ignoreLog, maxScrollCount) {
      maxScrollCount = maxScrollCount || 10;
      for (var index = 0; index < maxScrollCount; index++) {
        var results = this.captureExistsSomeText(
          contents,
          logOcrResults,
          ignoreLog
        );
        if (results.length > 0) {
          return results;
        }
        sleep(randomUtils$4.getRandom(1.5, 2, 1000));
        swipeUtils.swipeUp();
      }
      return [];
    },
  };

  var config$1 = {
    mobile: "18762750392",
    ignoreApps: [],
    logServer: "http://47.120.74.135",
  };

  var config = config$1;
  var logUtils$1 = {
    post(data) {
      var url = config.logServer + "/api/logs/add";
      return http.postJson(url, data);
    },
    log(msg, type) {
      type = type || 1;
      return this.post({
        battery: device.getBattery(),
        type: type,
        msg: msg,
        mobile: config.mobile,
        timeStamp: Date.now(),
      });
    },
  };

  var show = console.show;
  var hide = console.hide;
  console.show = function () {
    console.showing = true;
    show.apply(console, arguments);
  };
  console.hide = function () {
    console.showing = false;
    hide.apply(console, arguments);
  };

  var timeUtils$1 = timeUtils$3;
  var logUtils = logUtils$1;


  function Action$1(name, config) {
    this.name = name;
    this.maxAllowRunHour = config.maxAllowRunHour;
    this.minAllowRunHour = config.minAllowRunHour;
    this.maxRunSCount = config.maxRunSCount;
    this.maxRunFCount = config.maxRunFCount;
    this.interval = config.interval;
    this.todayIsOver = false;
    Object.defineProperty(this, "runSCount", {
      get() {
        return this.storage.get(this.name + "runSCount") || 0;
      },
      set(value) {
        this.storage.put(this.name + "runSCount", value);
      },
    });
    Object.defineProperty(this, "runFCount", {
      get() {
        return this.storage.get(this.name + "runFCount") || 0;
      },
      set(value) {
        this.storage.put(this.name + "runFCount", value);
      },
    });
  }
  Action$1.prototype.setStorage = function (storage) {
    this.storage = storage;
  };
  Action$1.prototype.goStartPage = function () {
    return true;
  };
  Action$1.prototype.beforeExec = function () {
    return true;
  };
  Action$1.prototype.exec = function () {
    throw new Error("Action.exec must be implemented");
  };
  Action$1.prototype.afterExec = function () {
    this.lastEndTime = Date.now();
  };
  Action$1.prototype.canFlow = function () {
    if (!this.checkAllowRunHour()) {
      return;
    }
    if (!this.checkRunCount()) {
      return;
    }
    if (!this.checkInterval()) {
      return;
    }
    if (this.todayIsOver) {
      return;
    }
    return true;
  };
  Action$1.prototype.flow = function () {
    console.show();
    if (!this.canFlow()) {
      console.hide();
      return;
    }
    if (this.goStartPage()) {
      var beforeExecResult = this.beforeExec();
      if (beforeExecResult) {
        logUtils.log(this.name + "开始执行");
        this.exec();
        this.afterExec();
        logUtils.log(this.name + "结束执行");
      } else {
        console.log(this.name, "beforeExec", "执行失败");
        logUtils.log(this.name + " beforeExec 执行失败");
      }
    } else {
      console.log(this.name, "goStartPage", "执行失败");
      logUtils.log(this.name + " goStartPage 执行失败");
    }
    console.hide();
  };
  Action$1.prototype.checkInterval = function () {
    if (this.interval && this.lastEndTime) {
      var hasExec = timeUtils$1.hasExec(this.lastEndTime);
      if (hasExec < this.interval) {
        console.log(this.name, "间隔时间未到", hasExec, "/", this.interval);
        return false;
      }
    }
    return true;
  };
  Action$1.prototype.checkAllowRunHour = function () {
    var hour = new Date().getHours();
    if (this.maxAllowRunHour) {
      if (hour >= this.maxAllowRunHour) {
        console.log(
          this.name,
          hour,
          "|",
          maxAllowRunHour,
          "最大允许执行时间已过"
        );
        return false;
      }
    }
    if (this.minAllowRunHour) {
      if (hour < this.minAllowRunHour) {
        console.log(
          this.name,
          hour,
          "|",
          minAllowRunHour,
          "最小允许执行时间未到"
        );
        return false;
      }
    }
    return true;
  };
  Action$1.prototype.checkRunCount = function () {
    if (this.maxRunSCount) {
      if (this.runSCount >= this.maxRunSCount) {
        console.log(
          this.name,
          this.runSCount,
          "|",
          this.maxRunSCount,
          "执行成功次数超过限制"
        );
        return false;
      }
    }
    if (this.maxRunFCount) {
      if (this.runFCount >= this.maxRunFCount) {
        console.log(
          this.name,
          this.runFCount,
          "|",
          this.maxRunFCount,
          "执行失败次数超过限制"
        );
        return false;
      }
    }
    return true;
  };

  var Action_1 = Action$1;

  var ocrUtils$3 = ocrUtils$4;
  var common$1 = {
    inHome() {
      var contents = ["视频", "小说"];
      var TextOCR = ocrUtils$3.captureExistsAllText(contents);
      if (TextOCR) {
        return true;
      }
      var contents = ["视频", "斗地主"];
      var TextOCR = ocrUtils$3.captureExistsAllText(contents);
      if (TextOCR) {
        return true;
      }
      var contents = ["视频", "我的"];
      var TextOCR = ocrUtils$3.captureExistsAllText(contents);
      if (TextOCR) {
        return true;
      }
      var contents = ["视频", "百度"];
      var TextOCR = ocrUtils$3.captureExistsAllText(contents);
      if (TextOCR) {
        return true;
      }
      return false;
    },
  };

  var pointMap$2 = {
    首页: {
      百度: [[22, 2180, 220, 2296], 1080, 2340],
      视频: [[220, 2180, 418, 2296], 1080, 2340],
      任务: [[440, 2180, 638, 2296], 1080, 2340],
      // 任务: [[440, 2240, 638, 2356], 1080, 2340],
      小说: [[660, 2180, 858, 2296], 1080, 2340],
      我的: [[858, 2180, 1056, 2296], 1080, 2340],
    },
    我的: {
      设置: [[984, 127, 1036, 179], 1080, 2340],
    },
    任务: {
      微信提现关闭: [[847, 599, 885, 638], 1080, 2340],
    },
  };

  var adCommon$2 = {
    maxAdCount: 0,
    adCount: 0,
  };

  var randomUtils$3 = randomUtils$6;
  var textUtils$3 = textUtils_1;
  var timeUtils = timeUtils$3;
  var clickUtils$2 = clickUtils$4;
  var ocrUtils$2 = ocrUtils$4;
  var adCommon$1 = adCommon$2;
  var adType1$1 = {
    watchAd(span, handleNextAd) {
      this.span = span;
      this.handleNextAd = handleNextAd;
      var startTime = Date.now();
      var count = 0;
      adCommon$1.adCount++;
      console.log("第", adCommon$1.adCount, "/", adCommon$1.maxAdCount, "个广告");
      while (true) {
        count++;
        var hasExec = timeUtils.hasExec(startTime);
        if (count % 5 == 0) {
          console.log("已经观看", hasExec, "/", this.span);
        }
        if (count >= 4 && this.isOver()) {
          this.stopAd();
          break;
        }
        if (hasExec > this.span) {
          if (count % 5 != 0) {
            console.log("已经观看", hasExec, "/", this.span, "将执行关闭广告");
          }
          this.stopAd();
          break;
        }
        sleep(2 * 1000);
      }
    },
    stopAd() {
      for (var index = 0; index < 2; index++) {
        back();
        sleep(randomUtils$3.getRandom(1.5, 2, 1000));
        var exitContents = [
          //prettier-disable
          "残忍离开",
          "坚持离开",
          "残忍退出",
          "坚持退出",
        ];
        var hasNextContents = [
          //prettier-disable
          "再看一个",
          "再看1个",
        ];
        if (adCommon$1.adCount >= adCommon$1.maxAdCount) {
          var TextUI = textUtils$3.existsOneTextStartsWith(exitContents);
          if (TextUI) {
            clickUtils$2.clickTextUI(TextUI);
            sleep(randomUtils$3.getRandom(1.5, 2, 1000));
            return;
          }
        } else {
          var TextUI = textUtils$3.existsOneTextStartsWith(hasNextContents);
          if (TextUI) {
            clickUtils$2.clickTextUI(TextUI);
            sleep(randomUtils$3.getRandom(1.5, 2, 1000));
            this.handleNextAd && this.handleNextAd();
            return;
          }
        }
        if (!this.inAd()) {
          console.log("没有广告，退出");
          return;
        }
      }
    },
    inAd() {
      var contents = [
        //prettier-disable
        "领取成功",
        "已领取",
        "已完成任务",
        "已获得",
        "广告",
        "反馈",
        "秒后领取奖励",
        "后可领取奖励",
        "完成任务",
      ];
      var TextUI = textUtils$3.existsOneTextStartsWith(contents);
      if (TextUI) {
        return TextUI;
      }
      var TextOCR = ocrUtils$2.captureExistsOneText(contents);
      if (TextOCR) {
        return TextOCR;
      }
      return false;
    },
    isOver() {
      var contents = [
        //prettier-disable
        "领取成功",
        "已领取",
        "已完成任务",
        "已获得",
      ];
      var TextOCR = ocrUtils$2.captureExistsOneText(contents);
      if (TextOCR) {
        return true;
      }
      sleep(10 * 1000);
      var TextUI = textUtils$3.existsOneTextStartsWith(contents);
      if (TextUI) {
        return true;
      }
    },
  };

  var randomUtils$2 = randomUtils$6;
  var textUtils$2 = textUtils_1;
  var adCommon = adCommon$2;
  var adType1 = adType1$1;
  var MAX_AD_INTERVAL = 45;
  var baiDu = {
    startWatchAd(maxAdCount) {
      adCommon.adCount = 0;
      adCommon.maxAdCount = maxAdCount || 5;
      this.getAdType();
    },
    getAdType() {
      var span = randomUtils$2.getRandom(MAX_AD_INTERVAL, MAX_AD_INTERVAL + 5);
      for (var index = 0; index < 5; index++) {
        var contents = ["秒后领取奖励", "后可领取奖励", "完成任务"];
        var TextUI = textUtils$2.existsOneTextEndsWith(contents);
        if (TextUI) {
          console.log("发现广告:", TextUI.text());
          adType1.watchAd(span, () => {
            this.getAdType();
          });
          return;
        }
        sleep(2 * 1000);
      }
      console.log("adBaiDu", "未知的adType");
    },
  };

  var adBaiDu = baiDu;
  var clickUtils$1 = clickUtils$4;
  var randomUtils$1 = randomUtils$6;
  var textUtils$1 = textUtils_1;
  var ocrUtils$1 = ocrUtils$4;
  var pointMap$1 = pointMap$2;
  var inTask$1 = {
    init() {
      if (this.overCheck()) {
        return;
      }
      if (this.adCheck()) {
        return;
      }
      if (this.keLingCheck()) {
        return;
      }
      if (this.signCheck()) {
        return;
      }
      if (this.wxCheck()) {
        return;
      }
    },
    wxCheck() {
      var content = "微信提现";
      var TextUI = textUtils$1.existsTextStartsWith(content);
      if (TextUI) {
        clickUtils$1.clickPointMap(pointMap$1.任务.微信提现关闭);
        sleep(randomUtils$1.getRandom(2, 3, 1000));
        return true;
      }
      var TextOCR = ocrUtils$1.captureExistsText(content);
      if (TextOCR) {
        clickUtils$1.clickPointMap(pointMap$1.任务.微信提现关闭);
        sleep(randomUtils$1.getRandom(2, 3, 1000));
        return true;
      }
      return false;
    },
    signCheck() {
      var contents = ["直接领取", "我知道了"];
      var TextUI = textUtils$1.existsTextStartsWith(contents);
      if (TextUI) {
        clickUtils$1.clickTextUI(TextUI);
        sleep(randomUtils$1.getRandom(2, 3, 1000));
        this.init();
        return true;
      }
      var TextOCR = ocrUtils$1.captureExistsOneText(contents);
      if (TextOCR) {
        clickUtils$1.clickTextOCR(TextOCR);
        sleep(randomUtils$1.getRandom(2, 3, 1000));
        this.init();
        return true;
      }
      return false;
    },
    overCheck() {
      var contents = [
        //prettier-ignore
        "开心收下",
        "立即收下",
      ];
      var TextUI = textUtils$1.existsOneTextStartsWith(contents);
      if (TextUI) {
        clickUtils$1.clickTextUI(TextUI);
        sleep(randomUtils$1.getRandom(1.5, 2, 1000));
        return true;
      }
      var contents = [
        //prettier-ignore
        "开心收下",
        "立即收下",
      ];
      var TextOCR = ocrUtils$1.captureExistsOneText(contents);
      if (TextOCR) {
        clickUtils$1.clickTextOCR(TextOCR);
        sleep(randomUtils$1.getRandom(1.5, 2, 1000));
        return true;
      }
    },
    keLingCheck() {
      var contents = ["可领"];
      var TextOCR = ocrUtils$1.captureExistsOneText(contents);
      if (TextOCR) {
        clickUtils$1.clickTextOCR(TextOCR);
        sleep(randomUtils$1.getRandom(1.5, 2, 1000));
        return true;
      }
    },
    adCheck() {
      var contents = [
        //prettier-ignore
        "看广告再得",
        "看广告得",
        "看广告领",
        "看视频再得",
        "看视频得",
        "看视频领",
        "观看视频再得",
        "观看视频得",
        "观看视频领",
      ];
      var TextUI = textUtils$1.existsOneTextStartsWith(contents);
      if (TextUI) {
        clickUtils$1.clickTextUI(TextUI);
        sleep(randomUtils$1.getRandom(3.5, 5, 1000));
        var maxAdCount = randomUtils$1.getRandom(1, 4);
        adBaiDu.startWatchAd(maxAdCount);
        this.init();
        return true;
      } else {
        return false;
      }
    },
  };

  var clickUtils = clickUtils$4;
  var randomUtils = randomUtils$6;
  var textUtils = textUtils_1;
  var ocrUtils = ocrUtils$4;
  var Action = Action_1;
  var common = common$1;
  var pointMap = pointMap$2;
  var inTask = inTask$1;
  var aTreasure$1 = new Action("宝箱", {});

  aTreasure$1.goStartPage = function () {
    if (common.inHome()) {
      if (randomUtils.possible(0, 10)) {
        clickUtils.clickPointMap(pointMap.首页.视频);
        sleep(randomUtils.getRandom(10, 30, 1000));
      }
      if (randomUtils.possible(90, 100)) {
        clickUtils.clickPointMap(pointMap.首页.小说);
        sleep(randomUtils.getRandom(5, 10, 1000));
      }
      clickUtils.clickPointMap(pointMap.首页.任务);
      sleep(randomUtils.getRandom(5, 10, 1000));
      return true;
    }
  };
  aTreasure$1.exec = function () {
    inTask.init();
    sleep(randomUtils.getRandom(2, 3, 1000));
    var content = "开宝箱得金币";
    var TextUI = textUtils.existsTextStartsWith(content);
    if (TextUI) {
      clickUtils.clickTextUI(TextUI);
      sleep(randomUtils.getRandom(2, 3, 1000));
      inTask.init();
      return;
    }
    var content = "开宝箱得金币";
    var TextOCR = ocrUtils.captureExistsText(content);
    if (TextOCR) {
      clickUtils.clickTextOCR(TextOCR);
      sleep(randomUtils.getRandom(2, 3, 1000));
      inTask.init();
      return;
    }
    var content = "明天再来";
    var TextOCR = ocrUtils.captureExistsText(content);
    if (TextOCR) {
      this.todayIsOver = true;
    }
  };

  var aTreasure_1 = aTreasure$1;

  var aTreasure = aTreasure_1;
  aTreasure.flow();

  return aTreasureTest;

})();
